package com.baofang.bao.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baofang.bao.entity.User;
import com.baofang.bao.repository.UserRepository;

@Service
public class UserServiceImpl implements IuserService {
	@Autowired
	private UserRepository userrepository;
	
	public List<User> getUsers(){
		return userrepository.findAll();
	}
	
	public User getUserById(Long id) {
		return userrepository.getOne(id);
	}
	
	public User saveUser(User user) {
		return userrepository.saveAndFlush(user);
	}

	@Override
	public String findByUserName(String userName) {
		// TODO Auto-generated method stub
		return userrepository.findByUserName(userName);
	}

	@Override
	public User findByUserNameAndPassword(String userName, String password) {
		// TODO Auto-generated method stub
		return userrepository.findByUserNameAndPassword(userName, password);
	}
}
